//
//  DarkModeBootcamp.swift
//  FCSwiftUI
//
//  Created by 冯宣超 on 2023/3/4.
//

import SwiftUI

struct DarkModeBootcamp: View {
    @Environment(\.colorScheme) var colorScheme
    
    var body: some View {
        NavigationStack {
            ScrollView {
                VStack(alignment: .leading, spacing: 20) {
                    MyText(foregroundColor: "primary")
                        .foregroundColor(.primary)
                    
                    MyText(foregroundColor: "secondary")
                        .foregroundColor(.secondary)
                    
                    MyText(foregroundColor: "black")
                        .foregroundColor(.black)
                    
                    MyText(foregroundColor: "white")
                        .foregroundColor(.white)
                    
                    MyText(foregroundColor: "red")
                        .foregroundColor(.red)
                    
                    MyText(foregroundColor: "globally adaptive!")
                        .foregroundColor(Color("AdaptiveColor"))
                    
                    MyText(foregroundColor: "locally adaptive!")
                        .foregroundColor(colorScheme == .light ? .green : .blue)
                }
            }
            .navigationTitle("Dark Model Bootcamp")
        }
    }
}

private struct MyText: View {
    @State var foregroundColor: String
    
    var body: some View {
        HStack {
            Text("This color is:")
            
            Text(foregroundColor.uppercased())
                .underline()
        }
    }
}

struct DarkModeBootcamp_Previews: PreviewProvider {
    static var previews: some View {
        DarkModeBootcamp()
    }
}
